/*
 * @Author: yangni 920556271@qq.com
 * @Date: 2023-12-10 12:14:27
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-01-18 11:28:29
 * @FilePath: /yt-devops/lib/pages/devices/device_tab/device_detail/electricity_meter_detail/electricity_meter_detail_controller.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'dart:async';

import 'package:get/get.dart';
import 'package:yt_devops/pages/devices/device_tab/device_detail/base_detail_controller/base_detail_controller.dart';
import 'package:yt_devops/utils/socket/use_subscribe.dart';

import 'electricity_meter_detail_model.dart';

class ElectricityMeterDetailController extends BaseDetailController {
  String title = '';

  UseSubsribe subsribe = UseSubsribe();

  late Stream<Map<String, dynamic>> dataStream;

  ElectricityMeterList model = ElectricityMeterList();

  List<ElectricityMeterModel> gridList = [];

  @override
  void onInit() {
    title = Get.arguments['deviceName'];
    var id = Get.arguments['deviceId'];
    var type = Get.arguments['type'];
    gridList = model.grid;

    connectStatus = Get.arguments['connectStatus'];

    super.onInit();

    dataStream = subsribe.start([id], true).stream.asBroadcastStream();
  }

  @override
  void onReady() {}

  @override
  void onClose() {
    subsribe.closeListen();
  }
}
